home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / dpkg / info / procps.preinst < prev    next >
Encoding:
Text File  |  2009-03-18  |  2.6 KB  |  103 lines

  1. #!/bin/sh
  2. # preinst script for procps
  3. #
  4. # see: dh_installdeb(1)
  5.  
  6. set -e
  7.  
  8. # summary of how this script can be called:
  9. #        * <new-preinst> `install'
  10. #        * <new-preinst> `install' <old-version>
  11. #        * <new-preinst> `upgrade' <old-version>
  12. #        * <old-preinst> `abort-upgrade' <new-version>
  13. # for details, see http://www.debian.org/doc/debian-policy/ or
  14. # the debian-policy package
  15.  
  16. # Prepare to remove a no-longer used conffile
  17. prep_rm_conffile()
  18. {
  19.     PKGNAME="$1"
  20.     CONFFILE="$2"
  21.  
  22.     if [ -e "$CONFFILE" ]; then
  23.     md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  24.     old_md5sum="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE'{s/ obsolete$//;s/.* //p}\"`"
  25.     if [ "$md5sum" != "$old_md5sum" ]; then
  26.         echo "Obsolete conffile $CONFFILE has been modified by you, renaming to .dpkg-bak"
  27.         mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  28.     else
  29.         mv -f "$CONFFILE" "$CONFFILE".dpkg-obsolete
  30.     fi
  31.     fi
  32. }
  33.  
  34. prep_mv_conffile()
  35. {
  36.   PKGNAME=$1
  37.   CONFFILE=$2
  38.  
  39.   if [ -e "$CONFFILE" ]; then
  40.     md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  41.     old_md5sum="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE'{s/ obsolete$//;s/.* //p}\"`"
  42.     if [ "$md5sum" = "$old_md5sum" ]; then
  43.       rm -f "$CONFFILE"
  44.     fi
  45.   fi
  46. }
  47.  
  48. upgradeoldconffile()
  49. {
  50.   f=/etc/init.d/procps.sh
  51.   [ ! -e "$f" ] && return
  52.  
  53.   curmd5=`md5sum "$f" |awk '{print $1}'`
  54.   oldmd5=`dpkg-query -W -f='${Conffiles}' procps | sed "{\\'^ $f ' ! d; s///}"`
  55.   [ "$curmd5" = "$oldmd5" ] && {
  56.       # The admin has not modified $f
  57.       echo "Preparing to remove obsolete, unmodified conffile: $f"
  58.       mv -fv "$f" "$f.from-preinst"
  59.       return
  60.     } >&2
  61.  
  62.     # The admim modified $f; cause a deliberate conffile prompt
  63.     echo "Moving obsolete conffile to new pathname:"
  64.     mv -fv "$f" "${f%.sh}"
  65. }
  66.  
  67.  
  68. case "$1" in
  69.     install)
  70.     if dpkg --compare-versions "$2" lt-nl 1:3.2.7-11ubuntu1; then
  71.         prep_rm_conffile procps /etc/sysctl.d/10-tcp-timestamps-workaround.conf
  72.     fi
  73.     if dpkg --compare-versions "$2" lt-nl 1:3.2.7-11ubuntu2; then
  74.         prep_rm_conffile procps /etc/sysctl.d/10-process-security.conf
  75.     fi
  76.     ;;
  77.     upgrade)
  78.       prep_mv_conffile procps "/etc/init.d/procps.sh"
  79.       if dpkg --compare-versions "$2" lt-nl 1:3.2.7-11ubuntu1; then
  80.         prep_rm_conffile procps /etc/sysctl.d/10-tcp-timestamps-workaround.conf
  81.       fi
  82.       if dpkg --compare-versions "$2" lt-nl 1:3.2.7-11ubuntu2; then
  83.         prep_rm_conffile procps /etc/sysctl.d/10-process-security.conf
  84.       fi
  85.     ;;
  86.     abort-upgrade)
  87.     ;;
  88.  
  89.     *)
  90.         echo "preinst called with unknown argument \`$1'" >&2
  91.         exit 1
  92.     ;;
  93. esac
  94.  
  95. # dh_installdeb will replace this with shell code automatically
  96. # generated by other debhelper scripts.
  97.  
  98.  
  99.  
  100. exit 0
  101.  
  102.  
  103.